package com.ruoyi.logisticsassignment.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.logisticsassignment.domain.Logisticsassignment;
import com.ruoyi.logisticsassignment.service.ILogisticsassignmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配送员Controller
 * 
 * @author sqltudent
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/logisticsassignment/logisticsassignment")
public class LogisticsassignmentController extends BaseController
{
    @Autowired
    private ILogisticsassignmentService logisticsassignmentService;

    /**
     * 查询配送员列表
     */
    @PreAuthorize("@ss.hasPermi('logisticsassignment:logisticsassignment:list')")
    @GetMapping("/list")
    public TableDataInfo list(Logisticsassignment logisticsassignment)
    {
        startPage();
        List<Logisticsassignment> list = logisticsassignmentService.selectLogisticsassignmentList(logisticsassignment);
        return getDataTable(list);
    }

    /**
     * 导出配送员列表
     */
    @PreAuthorize("@ss.hasPermi('logisticsassignment:logisticsassignment:export')")
    @Log(title = "配送员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Logisticsassignment logisticsassignment)
    {
        List<Logisticsassignment> list = logisticsassignmentService.selectLogisticsassignmentList(logisticsassignment);
        ExcelUtil<Logisticsassignment> util = new ExcelUtil<Logisticsassignment>(Logisticsassignment.class);
        util.exportExcel(response, list, "配送员数据");
    }

    /**
     * 获取配送员详细信息
     */
    @PreAuthorize("@ss.hasPermi('logisticsassignment:logisticsassignment:query')")
    @GetMapping(value = "/{assignmentId}")
    public AjaxResult getInfo(@PathVariable("assignmentId") Long assignmentId)
    {
        return success(logisticsassignmentService.selectLogisticsassignmentByAssignmentId(assignmentId));
    }

    /**
     * 新增配送员
     */
    @PreAuthorize("@ss.hasPermi('logisticsassignment:logisticsassignment:add')")
    @Log(title = "配送员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Logisticsassignment logisticsassignment)
    {
        return toAjax(logisticsassignmentService.insertLogisticsassignment(logisticsassignment));
    }

    /**
     * 修改配送员
     */
    @PreAuthorize("@ss.hasPermi('logisticsassignment:logisticsassignment:edit')")
    @Log(title = "配送员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Logisticsassignment logisticsassignment)
    {
        return toAjax(logisticsassignmentService.updateLogisticsassignment(logisticsassignment));
    }

    /**
     * 删除配送员
     */
    @PreAuthorize("@ss.hasPermi('logisticsassignment:logisticsassignment:remove')")
    @Log(title = "配送员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assignmentIds}")
    public AjaxResult remove(@PathVariable Long[] assignmentIds)
    {
        return toAjax(logisticsassignmentService.deleteLogisticsassignmentByAssignmentIds(assignmentIds));
    }
}
